#include <iostream>

using namespace std;
// tortoiseSvn
// code.google.com/p/program-school

const int N = 10;


  void Heapifu(int* a, int n,int i) {
    int tmp;
    int puk;
    for(puk = i;puk < n && ((2 * puk) + 2) <= n; puk++) {
        if((a[puk] >= a[(2 * puk) + 1]) && (a[puk] >= a[(2 * puk) + 2]) ) {
            cout<<"Im sleeping ";
            cout<<a[puk]<<' ';
            if(a[(2 * puk) + 1] > a[(2 * puk) + 2]) {
                tmp = a[puk];
                a[puk] = a[(2 * puk) + 1];
                a[(2 * puk) + 1] = tmp;
            }
            else {
                tmp = a[puk];
                a[puk] = a[(2 * puk) + 2];
                a[(2 * puk) + 2] = tmp;
            }
        }

        for(int y = 0;y < n; y++) {
            cout<<a[y];
        }
    }

}




int main() {

    int a[N] = { 4, 3, 1, 8, 6};
    int i = 0;
    cout << "popedik";
    cout << "Hello world!" << endl;
    Heapifu(a, N, i);
    return 0;
}
